/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


package vista.rrhh;

import java.awt.Rectangle;
import java.awt.Color;
import java.util.Iterator;
import modelo.Empleado;
import modelo.Especialidad;

/**
 *
 * @author Administrador
 */
public class ExplorarEmpleados_celdaDatos extends javax.swing.JPanel {

    private int id;
    private Empleado empleado;
    private int altura;
    
    
    /** Creates new form explorarCotizaciones_celda */
    public ExplorarEmpleados_celdaDatos() {
        initComponents();
        altura = this.getPreferredSize().height;
    }

    public int getId() {
        return id;
    }

    /*public void setId(int id) {
        this.id = id;
    }*/
    
    public Empleado getEmpleado() {
        return empleado;
    }

    public void setEmpleado(Empleado emp) {
        this.empleado = emp;
        this.id=emp.getOID();
        lblLegajo.setText(String.valueOf(emp.getLegajo()));
        lblEstado.setText(emp.getEstado().getNombre());
        lblNombre.setText(emp.getApellido()+", "+emp.getNombre());
        String especialidades = "<HTML><BODY style='text-align: center;'>";
        Iterator<Especialidad> itEspecialidades = emp.getEspecialidades().iterator();
        int countEsp=0;
        while(itEspecialidades.hasNext())
        {
            
            Especialidad especialidad = itEspecialidades.next();
            especialidades+=especialidad.getTipo().getNombre() + " (" + especialidad.getRango().getNombre() + ")<br>";

           // Rectangle celdaBounds = this.getBounds();
           // celdaBounds.height+=alturaAux;
          //  this.setBounds(celdaBounds);
            if(countEsp>3) {
                altura+=16;
            }
            //alturaAux+=16;
            countEsp++;
            
        }
        lblRango.setText(especialidades);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblNombre = new javax.swing.JLabel();
        lblRango = new javax.swing.JLabel();
        lblLegajo = new javax.swing.JLabel();
        lblasdASD = new javax.swing.JLabel();
        lblasdASD1 = new javax.swing.JLabel();
        lblEstado = new javax.swing.JLabel();

        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(375, 74));

        lblNombre.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        lblNombre.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        lblNombre.setText("Serj Tankian");

        lblRango.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblRango.setText("Experto");
        lblRango.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        lblLegajo.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblLegajo.setText("1234");

        lblasdASD.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N
        lblasdASD.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblasdASD.setText("Legajo:");

        lblasdASD1.setFont(new java.awt.Font("Tahoma", 2, 11)); // NOI18N
        lblasdASD1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblasdASD1.setText("Estado:");

        lblEstado.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblEstado.setText("Baja");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(22, 22, 22)
                        .addComponent(lblNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblasdASD1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblEstado, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(lblasdASD)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(lblLegajo, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lblRango, javax.swing.GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblRango, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(lblNombre)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblLegajo)
                            .addComponent(lblasdASD))
                        .addGap(1, 1, 1)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(lblEstado)
                            .addComponent(lblasdASD1))
                        .addContainerGap())))
        );
    }// </editor-fold>//GEN-END:initComponents

    

    @Override
    public String toString()
    {
        String retorno=lblNombre.getText()+" "+lblEstado.getText()+" "+lblLegajo.getText()+" "+lblRango.getText();
        return retorno;
    }
    public void setSelected(boolean flag)
    {
        if(flag)
        {
            this.setBackground(new Color(112,112,112));
        }
        else
        {
            this.setBackground(new Color(245,252,255));
        }
    }

    public int getAltura() {
        return altura;
    }

    public void setAltura(int altura) {
        this.altura = altura;
    }
    
    public String getEstado()
    {
        return this.lblEstado.getText();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel lblEstado;
    private javax.swing.JLabel lblLegajo;
    private javax.swing.JLabel lblNombre;
    private javax.swing.JLabel lblRango;
    private javax.swing.JLabel lblasdASD;
    private javax.swing.JLabel lblasdASD1;
    // End of variables declaration//GEN-END:variables

}
